const express = require('express')
const router = express.Router()

// 导入验证表单数据的中间件
const expressJoi = require('@escook/express-joi')

// 验证规则
const { reg_userInfo, reg_updatePsd, reg_avatar } = require('../schema/index')

const userInfoHandle = require('../router_handler/userinfo')

// 获取用户的基本信息
router.get('/userInfo', userInfoHandle.getUserInfo)

// 修改用户基本信息
router.post('/userInfo', expressJoi(reg_userInfo), userInfoHandle.updateUserInfo)

// 修改密码
router.post('/updatepsd', expressJoi(reg_updatePsd), userInfoHandle.updatePsd)

// 更换头像
router.post('/updatetar', expressJoi(reg_avatar), userInfoHandle.updateAvatar)

module.exports = router